/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bea.cliente.gui.builders;

import bea.cliente.core.GuiManagerState;
import bea.cliente.gui.controllers.MainScreenController;
import bea.cliente.gui.styles.ButtonStyles;
import bea.cliente.gui.styles.FontsStyles;
import bea.cliente.gui.styles.PanelStyles;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.builder.EffectBuilder;
import de.lessvoid.nifty.builder.LayerBuilder;
import de.lessvoid.nifty.builder.PanelBuilder;
import de.lessvoid.nifty.builder.ScreenBuilder;
import de.lessvoid.nifty.builder.TextBuilder;
import de.lessvoid.nifty.controls.button.builder.ButtonBuilder;
import de.lessvoid.nifty.controls.chatcontrol.builder.ChatBuilder;
import de.lessvoid.nifty.controls.dropdown.builder.DropDownBuilder;
import de.lessvoid.nifty.controls.label.builder.LabelBuilder;
import de.lessvoid.nifty.controls.listbox.builder.ListBoxBuilder;
import de.lessvoid.nifty.controls.textfield.builder.TextFieldBuilder;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.tools.Color;
import java.util.ArrayList;

/**
 *
 * @author Ivan
 */
public class MainScreenBuilder {

    public static final String BG_IMAGE = "Interface/images/loginBackground.jpg";
    /**
     * Constante com os valores possiveis de tipo de jogos
     */
    public static final ArrayList<String> GAME_TYPES = new ArrayList<String>();

    static {
        GAME_TYPES.add("Deathmatch");
        GAME_TYPES.add("Team Deathmatch");
        GAME_TYPES.add("Survivor");
        GAME_TYPES.add("Most Kill");
    }
    /**
     * Constante com os valores possiveis de tamanho de times
     */
    public static final ArrayList<String> TEAM_SIZES = new ArrayList<String>();

    static {
        TEAM_SIZES.add("Free For All");
        TEAM_SIZES.add("2x2");
        TEAM_SIZES.add("3x3");
        TEAM_SIZES.add("4x4");
        TEAM_SIZES.add("5x5");
    }
    /**
     * Constante com os valores possiveis de tamanho de times
     */
    public static final ArrayList<String> MAPS = new ArrayList<String>();

    static {
        MAPS.add("Dungeon of Broken Earth");
        MAPS.add("Dungeon of Black Dragon");
    }
    // ids
    public static String LB_ROOM_LIST = "lbMainRoomList";
    public static String LB_ROOM_LIST_NUMBER = "lbMainRoomListNumber";
    public static String LB_ROOM_LIST_NAME = "lbMainRoomListName";
    public static String LB_ROOM_LIST_GAME_TYPE = "lbMainRoomListGameType";
    public static String LB_ROOM_LIST_TEAM_SIZE = "lbMainRoomListTeamSize";
    public static String TXT_GAME_NAME_ID = "txtGameNameFilter";
    public static String DDL_GAME_TYPE_ID = "ddlGameTypeFilter";
    public static String DDL_TEAM_SIZE_ID = "ddlTeamSizeFilter";
    public static String DDL_MAP_ID = "ddlMapFilter";

    public static Screen build(Nifty nifty) {
        Screen mainScreen = new ScreenBuilder(GuiManagerState.MAIN_SCR) {

            {
                controller(new MainScreenController());
                // camada de fundo "background"
                layer(new LayerBuilder("backgroundLayer") {

                    {
                        // imagem de fundo da tela de login
                        backgroundImage(BG_IMAGE);
                    }
                });

                layer(new LayerBuilder("topLayer") {

                    {
                        childLayoutVertical();
                        panel(new PanelBuilder() {

                            {
                                width(percentage(100));
                                height("40");
                                style(PanelStyles.BLACK_STYLE);
                                childLayoutHorizontal();

                                panel(new PanelBuilder() {

                                    {
                                        width("150px");
                                        childLayoutCenter();
                                        control(new ButtonBuilder("graphicsOption", "Graphics") {

                                            {
                                                style(ButtonStyles.BED_BASIC);
                                                alignCenter();
                                                width("100px");
                                                interactOnClick("showGraphicsOptionsWindow()");
                                            }
                                        });
                                    }
                                });

                                panel(new PanelBuilder() {

                                    {
                                        alignCenter();
                                        width("150px");
                                        childLayoutCenter();
                                        control(new ButtonBuilder("audioOption", "Audio") {

                                            {
                                                style(ButtonStyles.BED_BASIC);
                                                width("100px");
                                                interactOnClick("showAudioOptionsWindow()");
                                            }
                                        });
                                    }
                                });

                            }
                        });

                        // efeito de entrada da layer de "top"
                        onStartScreenEffect(new EffectBuilder("move") {

                            {
                                effectParameter("mode", "in");
                                effectParameter("direction", "top");
                                effectParameter("length", "500");
                                effectParameter("inherit", "true");
                                effectParameter("startDelay", "0");
                            }
                        });
                    }
                });

                /**
                 * CAMADA DE DADOS DE SALA E SERVIDOR
                 */
                layer(new LayerBuilder("mainLayer") {

                    {
                        childLayoutCenter();
                        paddingTop("50px");
                        // painel principal dos dados das salas
                        panel(new PanelBuilder() {

                            {
                                width(percentage(80));
                                height(percentage(65));
                                style(PanelStyles.BLACK_STYLE);
                                alignCenter();
                                childLayoutHorizontal();

                                // panel left
                                panel(new PanelBuilder() {

                                    {
                                        width(percentage(75));
                                        childLayoutVertical();
                                        height("100%");
                                        // painel da listagem de salas
                                        panel(new PanelBuilder() {

                                            {
                                                width("100%");
                                                height("85%");
                                                childLayoutHorizontal();
                                                control(new ListBoxBuilder(LB_ROOM_LIST_NUMBER) {

                                                    {
                                                        displayItems(14);
                                                        selectionModeSingle();
                                                        optionalVerticalScrollbar();
                                                        hideHorizontalScrollbar();
                                                        //width("*"); // standard nifty width attribute
                                                        width("5%");
                                                    }
                                                });
                                                control(new ListBoxBuilder(LB_ROOM_LIST_NAME) {

                                                    {
                                                        displayItems(14);
                                                        selectionModeSingle();
                                                        optionalVerticalScrollbar();
                                                        hideHorizontalScrollbar();
                                                        //width("*"); // standard nifty width attribute
                                                        width("30%");
                                                    }
                                                });
                                                control(new ListBoxBuilder(LB_ROOM_LIST_GAME_TYPE) {

                                                    {
                                                        displayItems(14);
                                                        selectionModeSingle();
                                                        optionalVerticalScrollbar();
                                                        hideHorizontalScrollbar();
                                                        //width("*"); // standard nifty width attribute
                                                        width("30%");
                                                    }
                                                });
                                                control(new ListBoxBuilder(LB_ROOM_LIST_TEAM_SIZE) {

                                                    {
                                                        displayItems(14);
                                                        selectionModeSingle();
                                                        optionalVerticalScrollbar();
                                                        hideHorizontalScrollbar();
                                                        //width("*"); // standard nifty width attribute
                                                        width("30%");
                                                    }
                                                });
                                            }
                                        });
                                        // painel dos botoes
                                        panel(new PanelBuilder() {

                                            {
                                                width("100%");
                                                height("15%");
                                                childLayoutHorizontal();
                                                // botao "Entrar na Sala"
                                                panel(new PanelBuilder() {

                                                    {
                                                        width("33%");
                                                        height("100%");
                                                        childLayoutCenter();
                                                        control(new ButtonBuilder("btnEnterRoom", "Enter") {

                                                            {
                                                                style(ButtonStyles.BED_BASIC);
                                                                alignCenter();
                                                                valignCenter();
                                                                width("100px");
                                                            }
                                                        });
                                                    }
                                                });
                                                // botao "Criar partida"
                                                panel(new PanelBuilder() {

                                                    {
                                                        width("33%");
                                                        height("100%");
                                                        childLayoutCenter();
                                                        control(new ButtonBuilder("btnCreateRoom", "Create Match") {

                                                            {
                                                                style(ButtonStyles.BED_BASIC);
                                                                alignCenter();
                                                                valignCenter();
                                                                width("100px");
                                                                interactOnClick("showCreateRoomPanel()");
                                                            }
                                                        });
                                                    }
                                                });
                                                // botao "Atualizar lista de salas"
                                                panel(new PanelBuilder() {

                                                    {
                                                        width("33%");
                                                        height("100%");
                                                        childLayoutCenter();
                                                        control(new ButtonBuilder("btnRefreshRoomList", "Refresh") {

                                                            {
                                                                style(ButtonStyles.BED_BASIC);
                                                                alignCenter();
                                                                valignCenter();
                                                                width("100px");
                                                            }
                                                        });
                                                    }
                                                });
                                            }
                                        });
                                    }
                                });

                                // panel right
                                panel(new PanelBuilder() {

                                    {
                                        width(percentage(25));
                                        childLayoutVertical();
                                        padding("10px");
                                        // opcoes
                                        // NOME DA SALA
                                        panel(new PanelBuilder() {

                                            {
                                                width("80%");
                                                height("*");
                                                childLayoutVertical();
                                                // label nome da sala
                                                control(new LabelBuilder() {

                                                    {
                                                        text("Game Name: ");
                                                        backgroundColor("#FFF0");
                                                        width("100%");
                                                        textHAlignLeft();
                                                    }
                                                });// fim label nome da sala
                                                // input para o nome da sala
                                                control(new TextFieldBuilder(TXT_GAME_NAME_ID) {

                                                    {
                                                        width("80%");
                                                    }
                                                });
                                            }
                                        });// fim NOME DA SALA
                                        // TIPO DE JOGO
                                        panel(new PanelBuilder() {

                                            {
                                                width("80%");
                                                height("*");
                                                childLayoutVertical();
                                                control(new LabelBuilder() {

                                                    {
                                                        text("Game Type: ");
                                                        backgroundColor("#FFF0");
                                                        width("100%");
                                                        textHAlignLeft();
                                                    }
                                                });
                                                control(new DropDownBuilder(DDL_GAME_TYPE_ID) {

                                                    {
                                                        width("150px");
                                                    }
                                                });
                                            }
                                        });// fim TIPO DE JOGO
                                        // TAMANHO DO TIME
                                        panel(new PanelBuilder() {

                                            {
                                                width("80%");
                                                height("*");
                                                childLayoutVertical();
                                                control(new LabelBuilder() {

                                                    {
                                                        text("Team Size: ");
                                                        backgroundColor("#FFF0");
                                                        width("100%");
                                                        textHAlignLeft();
                                                    }
                                                });

                                                control(new DropDownBuilder(DDL_TEAM_SIZE_ID) {

                                                    {
                                                        width("150px");
                                                    }
                                                });
                                            }
                                        });// fim TAMANHO DO TIME
                                        // MAPA
                                        panel(new PanelBuilder() {

                                            {
                                                width("80%");
                                                height("*");
                                                childLayoutVertical();
                                                control(new LabelBuilder() {

                                                    {
                                                        text("Map: ");
                                                        backgroundColor("#FFF0");
                                                        width("100%");
                                                        textHAlignLeft();
                                                    }
                                                });
                                                control(new DropDownBuilder(DDL_MAP_ID) {

                                                    {
                                                        width("150px");
                                                    }
                                                });
                                            }
                                        });// fim MAPA
                                    }
                                });
                            }
                        });


                        //efeito de entrada da layer "main"
                        onStartScreenEffect(new EffectBuilder("move") {

                            {
                                effectParameter("mode", "in");
                                effectParameter("direction", "left");
                                effectParameter("length", "500");
                                effectParameter("inherit", "true");
                                effectParameter("startDelay", "500");
                            }
                        });
                    }
                }); // final da main layer

                /**
                 * CAMADA DE CHAT E INFORMAÇÕES DA CONTA
                 */
                layer(new LayerBuilder("bottomLayer") {

                    {
                        childLayoutCenter();
                        width(percentage(100));
                        height(percentage(100));
                        panel(new PanelBuilder() {

                            {
                                width(percentage(100));
                                height("200px");
                                valignBottom();
                                childLayoutHorizontal();

                                // panel informacoes da conta
                                panel(new PanelBuilder() {

                                    {
                                        width(percentage(30));
                                        height(percentage(100));
                                        style(PanelStyles.BLACK_STYLE);
                                        childLayoutVertical();
                                        // panel top
                                        panel(new PanelBuilder() {

                                            {
                                                width(percentage(100));
                                                height(percentage(25));
                                                childLayoutVertical();
                                                // painel contendo o nome e nivel do jogador
                                                panel(new PanelBuilder() {

                                                    {
                                                        width(percentage(100));
                                                        height(percentage(100));
                                                        childLayoutVertical();
                                                        // nome do jogador
                                                        control(new LabelBuilder("playerNameLabel", "Ivan") {

                                                            {
                                                                style(FontsStyles.GENERAL_WHITE_TEXT_20);
                                                                backgroundColor("#FFF0");
                                                                width(percentage(90));
                                                                textHAlignLeft();
                                                            }
                                                        });// fim do nome do jogador
                                                        // nivel do jogador
                                                        control(new LabelBuilder("playerLevelLabel", "Explorer") {

                                                            {
                                                                style(FontsStyles.GENERAL_WHITE_TEXT_12);
                                                                backgroundColor("#FFF0");
                                                                width(percentage(90));
                                                                textHAlignLeft();
                                                            }
                                                        });// fim do nivel do jogador
                                                    }
                                                });// fim do panel com nome do player
                                            }
                                        });// fim panel top
                                        // panel  bottom
                                        panel(new PanelBuilder() {

                                            {
                                                width(percentage(100));
                                                height(percentage(75));
                                                childLayoutHorizontal();
                                                // painel contendo os labels dos valores
                                                panel(new PanelBuilder() {

                                                    {
                                                        width(percentage(50));
                                                        height(percentage(100));
                                                        childLayoutVertical();
                                                        padding("5px");
                                                        //backgroundColor(Color.randomColor());
                                                        // Matches
                                                        control(new LabelBuilder() {

                                                            {
                                                                label("Matches: ");
                                                                backgroundColor("#FFF0");
                                                                width(percentage(100));
                                                                textHAlignLeft();
                                                            }
                                                        });// fim matches
                                                        // Victories
                                                        control(new LabelBuilder() {

                                                            {
                                                                label("Victories: ");
                                                                backgroundColor("#FFF0");
                                                                width(percentage(100));
                                                                textHAlignLeft();
                                                            }
                                                        });// fim Victories
                                                        // Tempo de jogo
                                                        control(new LabelBuilder() {

                                                            {
                                                                label("Played Time: ");
                                                                backgroundColor("#FFF0");
                                                                width(percentage(100));
                                                                textHAlignLeft();
                                                            }
                                                        });// fim Tempo de jogo
                                                        // Players Killed
                                                        control(new LabelBuilder() {

                                                            {
                                                                label("Players Killed: ");
                                                                backgroundColor("#FFF0");
                                                                width(percentage(100));
                                                                textHAlignLeft();
                                                            }
                                                        });// fim Players Killed
                                                        // Deaths
                                                        control(new LabelBuilder() {

                                                            {
                                                                label("Deaths: ");
                                                                backgroundColor("#FFF0");
                                                                width(percentage(100));
                                                                textHAlignLeft();
                                                            }
                                                        });// fim Deaths
                                                        // Monsters killed
                                                        control(new LabelBuilder() {

                                                            {
                                                                label("Monsters Killed: ");
                                                                backgroundColor("#FFF0");
                                                                width(percentage(100));
                                                                textHAlignLeft();
                                                            }
                                                        });// fim Monsters killed
                                                    }
                                                });
                                                // painel contendo os valores estatisticos
                                                panel(new PanelBuilder() {

                                                    {
                                                        width(percentage(50));
                                                        height(percentage(100));
                                                        childLayoutVertical();
                                                        padding("5px");
                                                        //backgroundColor(Color.randomColor());
                                                        // Matches Valores
                                                        control(new LabelBuilder() {

                                                            {
                                                                label("999");
                                                                backgroundColor("#FFF0");
                                                                width(percentage(100));
                                                                textHAlignRight();
                                                            }
                                                        });// fim matches Valores
                                                        // Victories Valores
                                                        control(new LabelBuilder() {

                                                            {
                                                                label("789");
                                                                backgroundColor("#0F00");
                                                                width(percentage(100));
                                                                textHAlignRight();
                                                            }
                                                        });// fim Victories Valores
                                                        // Tempo de jogo Valores
                                                        control(new LabelBuilder() {

                                                            {
                                                                label("40h 56m");
                                                                backgroundColor("#FFF0");
                                                                width(percentage(100));
                                                                textHAlignRight();
                                                            }
                                                        });// fim Tempo de jogo Valores
                                                        // Players Killed Valores
                                                        control(new LabelBuilder() {

                                                            {
                                                                label("467");
                                                                backgroundColor("#0F00");
                                                                width(percentage(100));
                                                                textHAlignRight();
                                                            }
                                                        });// fim Players Killed Valores
                                                        // Deaths Valores
                                                        control(new LabelBuilder() {

                                                            {
                                                                label("143");
                                                                backgroundColor("#F000");
                                                                width(percentage(100));
                                                                textHAlignRight();
                                                            }
                                                        });// fim Deaths Valores
                                                        // Monsters Killed Valores
                                                        control(new LabelBuilder() {

                                                            {
                                                                label("3567");
                                                                backgroundColor("#0F00");
                                                                width(percentage(100));
                                                                textHAlignRight();
                                                            }
                                                        });// fim Monsters Killed Valores
                                                    }
                                                });
                                            }
                                        });// fim panel bottom
                                    }
                                });// fim panel com informações do player

                                // panel chat
                                panel(new PanelBuilder() {

                                    {
                                        childLayoutCenter();
                                        width(percentage(50));
                                        height(percentage(100));
                                        style(PanelStyles.BLACK_STYLE);
                                        padding("5px");

                                        control(new ChatBuilder("mainChat", 6) {

                                            {
                                                font(FontsStyles.GENERAL_WHITE_TEXT_16);
                                                width(percentage(100));
                                                height(percentage(100));
                                            }
                                        });

                                    }
                                });

                                // panel comunidade(clan, amigos)
                                panel(new PanelBuilder() {

                                    {
                                        width(percentage(20));
                                        height(percentage(100));
                                        style(PanelStyles.BLACK_STYLE);
                                    }
                                });
                            }
                        });

                        //efeito de entrada da layer "bottom"
                        onStartScreenEffect(new EffectBuilder("move") {

                            {
                                effectParameter("mode", "in");
                                effectParameter("direction", "bottom");
                                effectParameter("length", "500");
                                effectParameter("inherit", "true");
                                effectParameter("startDelay", "0");
                            }
                        });
                    }
                }); // final da bottom layer

                layer(new LayerBuilder("layerMainScreenWindowsOptions") {

                    {
                        childLayoutAbsolute();
                    }
                });
                layer(new LayerBuilder("layerCreateRoom") {

                    {
                        childLayoutCenter();
                        panel(new PanelBuilder("pnlCreateRoom") {

                            {
                                style(PanelStyles.BLACK_STYLE);
                                width("60%");
                                height("60%");
                                valignCenter();
                                alignCenter();
                                visible(false);
                                // efeito de ENTRADA da tela de construção de salas
                                onShowEffect(new EffectBuilder("fade") {

                                    {
                                        effectParameter("start", "#00");
                                        effectParameter("end", "#ff");
                                    }
                                });
                                // efeito de SAIDA da tela de construção de salas
                                onHideEffect(new EffectBuilder("fade") {

                                    {
                                        effectParameter("start", "#ff");
                                        effectParameter("end", "#00");
                                    }
                                });
                            }
                        });
                    }
                });
            }
        }.build(nifty);
        
        return mainScreen;
    }
;
}
